#include "sequence.h"
#include "measure.h"
#include "settings.h"
#include <QDebug>


Sequence::Sequence(Settings *setting, Measure *measure)
    : mSetting(setting),
      mMeasure(measure)
{
    connect(&mTimer, SIGNAL(timeout()), this, SLOT(startMeasure()));

    startTimer();
}

Sequence::~Sequence() {
}

void Sequence::startTimer() {
    mCounter = 1;

    mMeasure->measureAll();
    mTimer.start(mSetting->getZyclus() * 1000); // Zyklus in mS
}

void Sequence::startMeasure() {
    if (mCounter++ < mSetting->countMeasures()) {
        mMeasure->measureAll();
    }
    else {
        mTimer.stop();
        qApp->exit();
    }
}
